<template>
	<view class="padding" :style="'height:'+screenHeight+'px;'">
		<view class="boxconten" style="height: 100%;">
			<view class="one">
				<view class="" style="color: #E6A23C;" v-if="item.Status==0">
					<span>待审核</span>
				</view>
				<view class="" style="color: #C0C0C0;" v-if="item.Status==1">
					<span>已邮寄</span>
				</view>
				<view class="" style="color: #27BF86;" v-if="item.Status==-1">
					<span>驳回</span>
				</view>
				<view class="" style="color: #0197F6;" v-if="item.Status==20">
					<span>已完成</span>
				</view>
			</view>
			<view class="two">
				<view style="twoicon"><u-icon name="clock" color="#878787" size="40" :label="item.CreateDateTime"></u-icon></view>
				<view style="twoicon"><u-icon name="account" color="#a1a1a1" size="40" :label="'手机： '+item.Mobile"></u-icon></view>
				<view style="twoicon"><u-icon name="account" color="#a1a1a1" size="40" :label="'收货人： '+item.LxrName"></u-icon></view>
				<view style="twoicon"><u-icon name="account" color="#a1a1a1" size="40" :label="'身份证： '+item.SFZ"></u-icon></view>
				<view style="twoicon"><u-icon name="chat" color="#a1a1a1" size="40" :label="'备注：\n'+item.Memo"></u-icon></view>
			</view>
			<view class="three">
				<span>单号：{{item.OrderNumber}}</span>
			</view>
			<view class="three" v-if="item.KDH!=''">
				<span>快递号：{{item.KDH}}</span>
			</view>
			<!-- <view class="qrcodes">
				<uv-qrcode ref="qrcode" size="300rpx" :value="item.OrderNumber"></uv-qrcode>
			</view> -->
			<view class="four">
				<view v-if="item.Status==0">
					<u-button @click="payment(item.SQDId)" type="success">取消审核</u-button>
				</view>
				<!-- <view class="cuichul" v-if="item.Status==1">
					<u-button @click="deleteshow=true" type="default">催处理</u-button>
				</view> -->
				<!-- <view v-if="item.Status==2" >
					<u-button @click="cancellationshow=true" type="success">取消预约</u-button>
				</view>
				 -->
				<view v-if="item.Status==-1">
					<u-button type="success">重新审核</u-button>
				</view>
			</view>
		</view>
		<u-modal v-model="cancellationshow" :content="cancellationtext" @confirm="cancellation" :mask-close-able="true" :show-cancel-button="true"></u-modal>
		<u-modal v-model="deleteshow" :content="deletetext" @confirm="deletes" :mask-close-able="true" :show-cancel-button="true"></u-modal>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				screenHeight: getApp().globalData.screenHeight-44,
				SQDId:'',
				cancellationtext:'取消预约后将无法撤回，是否取消',
				cancellationshow:false,
				deletetext:'删除记录后无法找回，是否删除',
				deleteshow:false,
				item: {
					DoctorName: "",
					DptId: "",
					DptName: "",
					Memo: "",
					Mobile: "",
					SQDId: "",
					OrderNumber: "",
					PatientName: "",
					PayNumber: "",
					Status: '',
					VisitDay: "",
					VisitTime: "",
					GHF:0
				},
				openid:'',
				sessionkey:'',
				appid:''
				
			}
		},
		onLoad(option) {
			this.SQDId=option.SQDId
			console.log("option.SQDId",option.SQDId)
			this.getDetail()
		},
		computed: {

		},
		methods: {
			getDetail(){
				uni.showLoading({
					title: '请稍后'
				})
				this.$request("sqd","detail",{
					SQDId:this.SQDId
				}).then(res=>{
					console.log("详情",res)
					if (res.code == 1) {
						this.item=res.data
						uni.hideLoading();
						
					}else{
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
			deletes(){
				this.$request("Order", "Delete", {
					OrderNo: this.item.OrderNumber
				}).then(res => {
					if (res.code == 1) {
						console.log("res",res)
						if (res.code == 1) {
							uni.showToast({
								title: '删除成功',
								icon: 'none',
								duration: 1000
							});
							setTimeout(function() {
								uni.redirectTo({
									url: `/pages/register/Scheduling/record/record?current=${3}`,
									fail(error) {
										console.log(error)
									}
								})
								return
							}, 1000);
						}
					}else{
						uni.showToast({
							title: '删除失败',
							icon: 'none',
							duration: 1000
						});
					}
				})
			},
			payment(SQDId){
				uni.showLoading({
					title: '请等待'
				})
				this.$request("sqd", "delete", {
					SQDId: SQDId
				}).then(res => {
					console.log(res)
					if (res.code == 1) {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 1000
						});
						uni.hideLoading();
						uni.navigateBack()
					}else{
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 1000
						});
						uni.navigateBack()
					}
				})
			},
			cancellation(){
				console.log("进了")
				this.$request("pay", "refund", {
					OrderNo: this.item.OrderNumber
				}).then(res => {
					console.log("res",res)
					if (res.code == 1) {
						uni.showToast({
							title: '取消成功',
							icon: 'none',
							duration: 1000
						});
						setTimeout(function() {
							uni.redirectTo({
								url: `/pages/register/Scheduling/record/record?current=${1}`,
								fail(error) {
									console.log(error)
								}
							})
							return
						}, 1000);
					}else{
						uni.showToast({
							title: '取消失败',
							icon: 'none',
							duration: 1000
						});
					}
				})
			},
			formattedDatemonth(VisitDay) {
				const date = new Date(VisitDay);
				return date.toLocaleDateString('zh-CN', {
					month: 'short'
				}).replace(/\//g, '月');
			},
			formattedDateday(VisitDay) {
				const date = new Date(VisitDay);
				return date.toLocaleDateString('zh-CN', {
					day: 'numeric'
				}).replace(/\//g, '月');
			}
		}
	}
</script>

<style>
	@import './fapiao.css';
</style>